package cn.com.mqtt.consumer.controller;
 
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.mqtt.consumer.MqttConsumerConfig;
 
 
@Controller
@RequestMapping("/mqtt/consumer")
public class TestController {
    @Autowired
    private MqttConsumerConfig client;
 
    @Value("${spring.mqtt.client.id}")
    private String clientId;
 
    @PostMapping("/connect")
    @ResponseBody
    public String connect(){
        client.connect();
        return clientId + "连接到服务器";
        // return "consumer-id连接到服务器";
    }
 
    @PostMapping("/disConnect")
    @ResponseBody
    public String disConnect(){
        client.disConnect();
        return clientId + "与服务器断开连接";
        // return "consumer-id与服务器断开连接";
    }
}